package objbo.xmlparser.controls.action;

import org.eclipse.jface.action.Action;

import objbo.xmlparser.model.bean.ElementBean;
import objbo.xmlparser.view.interfaces.ElementInterFace;
import objbo.xmlparser.view.interfaces.UIInterFace;
import objbo.xmlparser.view.ui.AttributeListUI;

public class AttributeListModifyAction extends Action
{
	private UIInterFace uIInterFace = null;
	private ElementInterFace elementInterFace = null;
	private AttributeListUI ui = null;
	
	public AttributeListModifyAction(ElementInterFace elementInterFace, UIInterFace uIInterFace)
	{
		this.elementInterFace = elementInterFace;
		this.uIInterFace = uIInterFace;
	}
	
	public void setAttributeListUI(AttributeListUI ui)
	{
		this.ui = ui;
	}
	
	@Override
	public void run()
	{
		Object[] data = null;
		if(ui.getdata() == null)
		{
			return;
		}
		
		data = ui.getdata();
		
		ElementBean elementBean = (ElementBean) data[0];
		String name = (String) data[1];
		String attData = (String) data[2];
		int index = (Integer) data[3];
		
		if(elementBean == null || name == null || data[2] == null)
		{return;}
		
		this.elementInterFace.ModifyAttribute(elementBean, name, attData, index);
		this.uIInterFace.setTabElementData(elementBean);
		//this.uIInterFace.refreshTreeUI();
	}
}
